import { isPasswordSafety, isUserName } from "@/utils/index";

let passwordValidate = (rule, value, callback) => {
  if (value.length === 0) {
    callback(new Error("请输入密码"));
  } else if (!isPasswordSafety(value)) {
    callback(new Error("请输入包含数字和字母结合的6-18位密码"));
  } else {
    callback();
  }
};

let userNameValidate = (rule, value, callback) => {
  if (value.length === 0) {
    callback(new Error("请输入账号"));
  } else if (!isUserName(value)) {
    callback(new Error("请输入6-18位字符，只能包含数字、英文字母、下划线"));
  } else {
    callback();
  }
};
let userPasswordValidate = (rule, value, callback) => {
  if (value.length === 0) {
    callback();
  } else if (!isPasswordSafety(value)) {
    callback(new Error("请输入6-18位字符，必须包含英文字母+数字，区分大小写"));
  } else {
    callback();
  }
};

export const RULES = {
  smsTemplate: {
    templateid: [{ required: true, message: "请输入模板ID", trigger: "blur" }],
    smsid: [{ required: true, message: "请选择短信通道代码", trigger: "change" }],
    sms_type: [{ required: true, message: "请选择短信类型", trigger: "change" }],
    template_value: [{ required: true, message: "请输入短信模板内容", trigger: "blur" }],
    mark_login: [{ required: true, message: "请选择是否需要登录", trigger: "change" }],
    dypt: [{ required: true, message: "请输入调用平台", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 表单设置-->自定义按钮-->新增/编辑
  designButton: {
    buttonCode: [{ required: true, message: "请输入按钮编码", trigger: "blur" }],
    buttonName: [{ required: true, message: "请输入按钮名称", trigger: "blur" }]
  },
  // 导出运维-->导出配置-->新增/编辑
  databaseConfiguration: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "blur" }],
    dbname: [{ required: true, message: "请输入数据库名称", trigger: "blur" }],
    dbtype: [{ required: true, message: "请输入数据库类型", trigger: "change" }],
    dblink: [{ required: true, message: "请输入数据库链", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请输入启用标志", trigger: "change" }]
  },
  // 导出运维-->导出配置-->新增/编辑
  exportConfiguration: {
    exportid: [{ required: true, message: "请选择导出代码", trigger: "blur" }],
    export_name: [{ required: true, message: "请输入导出名称", trigger: "blur" }],
    export_format: [{ required: true, message: "请输入导出格式", trigger: "blur" }],
    export_pz: [{ required: true, message: "请输入配置信息", trigger: "blur" }],
    export_dblinkiid: [{ required: true, message: "请输入数据库连接ID", trigger: "change" }],
    mark_enabled: [{ required: true, message: "请输入启用标志", trigger: "change" }],
    remarks: [{ required: true, message: "请输入备注", trigger: "blur" }]
  },
  // 系统设置-->单号管理-->新增/编辑
  orderNoManagement: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    codeid: [{ required: true, message: "请输入单号代码", trigger: "blur" }],
    codestring: [{ required: true, message: "请输入单号格式", trigger: "blur" }],
    datestring: [{ required: true, message: "请输入日期格式", trigger: "blur" }],
    value_len: [{ required: true, message: "请输入值长", trigger: "blur" }],
    value_now: [{ required: true, message: "请输入目前值", trigger: "blur" }],
    value_type: [{ required: true, message: "请输入值类型", trigger: "blur" }],
    value_start: [{ required: true, message: "请输入开始值", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->数据库连接-->新增/编辑
  databaseConnectionRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    dbname: [{ required: true, message: "请输入数据库名称", trigger: "blur" }],
    dbtype: [{ required: true, message: "请选择数据库类型", trigger: "change" }],
    dblink: [{ required: true, message: "请输入数据库链", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->参数管理-->新增/编辑
  parameterManagement: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    paraid: [{ required: true, message: "请输入参数ID", trigger: "blur" }],
    para_name: [{ required: true, message: "请输入参数名称", trigger: "blur" }],
    para_value: [{ required: true, message: "请输入参数值", trigger: "blur" }],
    para_type: [{ required: true, message: "请输入参数类型", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->系统host-->新增/编辑
  systemHostRules: {
    hostid: [{ required: true, message: "请输入主机ID", trigger: "blur" }],
    hostcode: [{ required: true, message: "请输入主机代码", trigger: "blur" }],
    hostname: [{ required: true, message: "请输入主机名称", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },

  // 好会付-->银行行号运维-->新增/编辑
  bankDialogRules: {
    yhhh: [{ required: true, message: "请输入银行行号", trigger: "blur" }],
    yhmc: [{ required: true, message: "请输入银行名称", trigger: "blur" }],
    dhdm: [{ required: true, message: "请输入大行代码", trigger: "blur" }],
    dhmc: [{ required: true, message: "请输入大行名称", trigger: "blur" }],
    shengid: [{ required: true, message: "请选择省份", trigger: "change" }],
    shiid: [{ required: true, message: "请选择城市", trigger: "change" }],
    dhdm2: [{ required: true, message: "请输入dhdm2代码", trigger: "blur" }],
    dhmc2: [{ required: true, message: "请输入dhmc2名称", trigger: "blur" }],
  },

  // 网关配置-->配置限制-->新增/编辑
  limitConfigRules: {
    hostid: [{ required: true, message: "请输入主机ID", trigger: "blur" }],
    limit_type: [{ required: true, message: "请选择限制类型", trigger: "change" }],
    limit_key: [{ required: true, message: "请输入限制键值", trigger: "blur" }],
    limit_timespan: [{ required: true, message: "请输入时间间隔", trigger: "blur" }],
    limit_nums: [{ required: true, message: "请输入次数", trigger: "blur" }]
  },
  // 系统设置-->服务配置-->新增/编辑
  serviceConfigRules: {
    servicename: [{ required: true, message: "请输入微服务名称", trigger: "blur" }],
    servicescheme: [{ required: true, message: "请输入微服务类型", trigger: "change" }],
    serviceurl: [{ required: true, message: "请输入微服务地址", trigger: "blur" }],
    serviceid: [{ required: true, message: "请输入微服务ID", trigger: "blur" }],
    servicekeys: [{ required: true, message: "请输入微服务秘钥", trigger: "blur" }],
    mark_service: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->调用者秘钥-->新增/编辑
  callerKeysRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    call_caller: [{ required: true, message: "请输入调用者", trigger: "blur" }],
    client_type: [{ required: true, message: "请选择调用者类型", trigger: "change" }],
    start_time: [{ required: true, message: "请选择开始时间", trigger: "blur" }],
    end_time: [{ required: true, message: "请选择截止时间", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->秘钥角色-->新增/编辑
  keysRoleRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    call_caller: [{ required: true, message: "请选择调用者", trigger: "change" }],
    roleid: [{ required: true, message: "请选择角色", trigger: "change" }]
  },
  // 系统设置-->系统方法-->新增/编辑
  systemMethodRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "blur" }],
    call_method: [{ required: true, message: "请输入方法代码", trigger: "blur" }],
    call_name: [{ required: true, message: "请输入方法名称", trigger: "blur" }],
    serviceid: [{ required: true, message: "请选择微服务", trigger: "change" }],
    route1: [{ required: true, message: "请输入路由1", trigger: "blur" }],
    isdebug: [{ required: true, message: "请选择是否调试", trigger: "change" }],
    islogin: [{ required: true, message: "请选择是否登录", trigger: "change" }],
    mark_system: [{ required: true, message: "请选择系统方法", trigger: "change" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->方法权限-->新增/编辑
  methodAuthorityRules: {
    hostid: [{ required: true, message: "请选择主机id", trigger: "change" }],
    roleid: [{ required: true, message: "请选择角色", trigger: "change" }],
    call_method: [{ required: true, message: "请输入方法", trigger: "blur" }]
  },
  // 系统设置-->系统用户-->新增/编辑
  systemUserRules: {
    loginid: [{ required: true, message: "请输入登录ID", trigger: "blur" }],
    username: [{ required: true, message: "请输入用户名称", trigger: "blur" }],
    loginpwd: [{ required: true, validator: passwordValidate, trigger: "blur" }],
    user_tel: [{ required: true, message: "请输入手机号码", trigger: "blur" }],
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    user_email: [{ required: true, message: "请输入邮件地址", trigger: "blur" }],
    sort_code: [{ required: true, message: "请输入排序", trigger: "blur" }],
    mark_enabled: [{ required: true, message: "请选择启用标志", trigger: "change" }]
  },
  // 系统设置-->角色管理-->新增/编辑
  roleManagementRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    roleid: [{ required: true, message: "请输入角色ID", trigger: "blur" }],
    rolename: [{ required: true, message: "请输入角色名称", trigger: "blur" }]
  },
  // 用户管理-->角色-->新增/编辑
  midRoleManagerRules: {
    RoleName: [{ required: true, message: "请输入角色名称", trigger: "blur" }]
  },
  // 用户管理-->角色组-->新增/编辑
  midRoleGroupManagerRules: {
    RoleGroupName: [{ required: true, message: "请输入角色组名称", trigger: "blur" }]
  },
  // 用户管理-->组织机构-->新增/编辑
  midInstitutionRules: {
    OrgName: [{ required: true, message: "请输入组织机构名称", trigger: "blur" }],
    OrgCode: [{ required: true, message: "请输入组织机构代码", trigger: "blur" }],
    OrgBindEnterID: [{ required: true, message: "请选择关联企业信息", trigger: "change" }]
  },
  // 用户管理-->部门-->新增/编辑
  midDepartmentRules: {
    OrgID: [{ required: true, message: "请选择所属机构", trigger: "change" }],
    UnitName: [{ required: true, message: "请输入部门名称", trigger: "blur" }],
    UnitCode: [{ required: true, message: "请输入部门代码", trigger: "blur" }]
  },
  // 用户管理-->菜单-->新增/编辑
  midMenuManagerRules: {
    ParentMenuID: [{ required: true, message: "请选择", trigger: "change" }],
    MenuName: [{ required: true, message: "请输入菜单名称", trigger: "blur" }],
    MenuPath: [{ required: true, message: "请输入菜单路径", trigger: "blur" }]
  },
  // 用户管理-->按钮-->新增/编辑
  midButtonManagerRules: {
    MenuID: [{ required: true, message: "请选择菜单", trigger: "change" }],
    Name: [{ required: true, message: "请输入按钮名称", trigger: "blur" }],
    Path: [{ required: true, message: "请输入按钮路径", trigger: "blur" }]
  },
  //  用户管理-->用户-->新增/编辑
  midUserManagerRules: {
    OrgID: [{ required: true, message: "请选择机构", trigger: "change" }],
    UnitID: [{ required: true, message: "请选择部门", trigger: "change" }],
    UserName: [{ required: true, validator: userNameValidate, trigger: "blur" }],
    RealName: [{ required: true, message: "请输入姓名", trigger: "blur" }],
    MobliePhone: [{ required: true, message: "请输入手机号", trigger: "blur" }],
    PassWord: [{ required: false, validator: userPasswordValidate, trigger: "blur" }]
  },
  //  用户管理-->系统-->新增/编辑
  sysManagerDialogRules: {
    // hostid: [{ required: true, message: "请输入系统ID", trigger: "blur" }],
    hostname: [{ required: true, message: "请输入系统名称", trigger: "blur" }],
    hostcode: [{ required: true, message: "请输入系统code", trigger: "blur" }]
  },
  // 系统设置-->用户授权-->新增/编辑
  userAuthorizeRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    userid: [{ required: true, message: "请选择用户ID", trigger: "change" }],
    roleid: [{ required: true, message: "请选择角色ID", trigger: "change" }]
  },
  // 系统设置-->模块管理-->新增/编辑
  moduleManagementRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    menu_type: [{ required: true, message: "请选择菜单类型", trigger: "change" }],
    menu_name: [{ required: true, message: "请输入模块名称", trigger: "blur" }],
    menucode: [{ required: true, message: "请输入路由名称", trigger: "blur" }],
    menu_path: [{ required: true, message: "请输入路由地址", trigger: "blur" }]
  },
  // 系统设置-->节点管理-->新增/编辑
  nodeManagementRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    menu_type: [{ required: true, message: "请选择菜单类型", trigger: "change" }],
    pmenuid: [{ required: true, message: "请选择父级菜单", trigger: "change" }],
    menu_name: [{ required: true, message: "请输入节点名称", trigger: "blur" }],
    menucode: [{ required: true, message: "请输入路由名称", trigger: "blur" }],
    menu_path: [{ required: true, message: "请输入路由地址", trigger: "blur" }]
  },
  // 系统设置-->菜单管理-->新增/编辑
  menuManagementRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    menu_type: [{ required: true, message: "请选择菜单类型", trigger: "change" }],
    twoMenuid: [{ required: true, message: "请选择模块菜单", trigger: "change" }],
    oneMenuid: [{ required: true, message: "请选择一级菜单", trigger: "change" }],
    pmenuid: [{ required: true, message: "请选择二级菜单", trigger: "change" }],
    menu_name: [{ required: true, message: "请输入菜单名称", trigger: "blur" }],
    menucode: [{ required: true, message: "请输入路由名称", trigger: "blur" }],
    menu_path: [{ required: true, message: "请输入路由地址", trigger: "blur" }]
  },
  // 系统设置-->菜单角色-->新增/编辑
  menuRoleRules: {
    hostid: [{ required: true, message: "请选择主机ID", trigger: "change" }],
    roleid: [{ required: true, message: "请选择角色ID", trigger: "change" }]
  },
  // 用户管理-->用户列表-->新增/编辑
  userManagerRules: {
    UserName: [{ required: true, message: "请输入账号", trigger: "blur" }],
    PassWord: [{ required: true, validator: passwordValidate, trigger: "blur" }],
    RealName: [{ required: true, message: "请输入姓名", trigger: "blur" }],
    Gender: [{ required: true, message: "请选择性别", trigger: "change" }],
    MobliePhone: [{ required: true, message: "请输入手机号码", trigger: "blur" }],
    Status: [{ required: true, message: "请选择启用标志", trigger: "blur" }],
    IsInside: [{ required: true, message: "请选择是否内部企业", trigger: "change" }]
  },

  ddmgInstitutionRules: {
    OrgName: [{ required: true, message: "组织机构名称不能为空", trigger: "blur" }],
    OrgBindEnterID: [{ required: true, message: "关联企业信息不能为空", trigger: "change" }]
  },

  ddmgManagerTeamRules: {
    TeamName: [{ required: true, message: "请输入团队名称", trigger: "blur" }],
    EstablishTime: [{ required: true, message: "请选择成立时间", trigger: "blur" }]
  },

  // 企业管理-->企业列表列表-->新增/编辑
  enterpriseDialogRules: {
    Enterp_Name: [{ required: true, message: "请输入企业名称", trigger: "blur" }],
    Area: [{ required: true, message: "请选择地区", trigger: "change" }],
    RegisteredAddress: [{ required: true, message: "请输入地址", trigger: "blur" }],

    Enterp_Contacts: [{ required: true, message: "请输入联系人", trigger: "blur" }],
    Enterp_ContactsPhone: [{ required: true, message: "请输入联系方式", trigger: "blur" }]
  },
  // 企业审核
  enterpriseAuditDialogRules: {
    Legalperson: [{ required: true, message: "请输入法人代表", trigger: "blur" }],
    IDCard: [{ required: true, message: "请输入法人身份证", trigger: "blur" }],
    PaidInCapital: [{ required: true, message: "请输入注册资本", trigger: "blur" }],
    TaxpayerIdentityNumber: [{ required: true, message: "请输入税号", trigger: "blur" }],
    RegisteredAddress: [{ required: true, message: "请输入地址", trigger: "blur" }],

    BusinessType: [{ required: true, message: "请选择业务信息", trigger: "change" }],

    LicenseUrl: [{ required: true, message: "请上传营业执照", trigger: "change" }],
    AuthorizeUrl: [{ required: true, message: "请上传企业授权书", trigger: "change" }],
    checkedList: [{ type: "array", required: true, message: "请至少选择一种身份!", trigger: "change" }],
    enterpRolesId: [{ required: true, message: "请选择企业会员角色", trigger: "change" }],

    AuditStatus: [{ required: true, message: "请选择审核结果", trigger: "change" }],
    AuditRemarks: [{ required: true, message: "请输入说明", trigger: "blur" }]
  },

  // 业务信息编辑
  businessInfoDialogRules: {
    checkedList: [{ type: "array", required: true, message: "请至少选择一种身份!", trigger: "change" }],
    enterpRolesId: [{ required: true, message: "请选择企业会员角色", trigger: "change" }],
    BusinessPic: [{ required: true, message: "请选择营业执照", trigger: "change" }],
    WrittenAuthorization: [{ required: true, message: "请选择企业授权书", trigger: "change" }],
    AdminUserId: [{ required: true, message: "请选择管理员", trigger: "change" }]
  },

  // 大大买钢网后台--> 企业会员角色-->弹框
  enterpriseVIPRoleRules: {
    WholeRoleName: [{ required: true, message: "请输入角色名称", trigger: "blur" }]
  },

  // 大大买钢网后台--> 管理员审核-->审核
  ddmgAdminAuditRules: {
    ApplyStatus: [{ required: true, message: "请选择审核结果", trigger: "change" }],
    AuthorizeFile: [{ required: true, message: "请选择企业授权书", trigger: "change" }]
  },
  // 大大买钢网后台--> 权限审核-->审核
  ddmgPermissionAuditRules: {
    Status: [{ required: true, message: "请选择审核结果", trigger: "change" }]
  },

  // 大大买钢网后台--> 经理人审核-->审核
  ddmgManagerAuditRules: {
    ManagerTypeCode: [{ required: true, message: "请选择审核结果", trigger: "change" }]
  },

  // 大大买钢网后台--> 经理人审核-->批量设置经理人
  ddmgSetManagerRules: {
    ManagerType: [{ required: true, message: "请先选择要批量设置的经理人类型", trigger: "change" }]
  },

  //单据设计-项目设计
  projectDialog: {
    projectName: [{ required: true, message: "请输入项目名称", trigger: "blur" }],
    projectDescribe: [{ required: true, message: "请输入项目描述", trigger: "blur" }],
    projectAuthor: [{ required: true, message: "请输入项目作者", trigger: "blur" }],
    templateName: [{ required: true, message: "请选择模板名称", trigger: "change" }]
  },

  //单据设计-项目模板
  templateDialog: {
    templateName: [{ required: true, message: "请输入模板名称", trigger: "blur" }],
    templateDescribe: [{ required: true, message: "请输入模板描述", trigger: "blur" }],
    templateAuthor: [{ required: true, message: "请输入模板作者", trigger: "blur" }],
    languageTypes: [{ required: true, message: "请选择语言类型", trigger: "change" }],
    uploadFile: [{ required: true, message: "请上传模板", trigger: "change" }]
  },
  //系统设置-数据字典
  datumDialog: {
    dictionaryName: [{ required: true, message: "请输入字典名称", trigger: "blur" }],
    dictionaryCode: [{ required: true, message: "请输入字典编码", trigger: "blur" }]
  },
  //系统设置-数据源
  sourceDialog: {
    databaseName: [{ required: true, message: "请输入数据源名称", trigger: "blur" }],
    databaseUrl: [{ required: true, message: "请输入数据源Url", trigger: "blur" }],
    username: [{ required: true, message: "请输入账号", trigger: "blur" }],
    password: [{ required: true, message: "请输入密码", trigger: "blur" }]
  },

  ListDialog: {
    itemKey: [{ required: true, message: "请输入名称", trigger: "blur" }],
    itemValue: [{ required: true, message: "请输入数据值", trigger: "blur" }]
  },
  addPositionDialog: {
    TitleName: [{ required: true, message: "请输入职位名称", trigger: "blur" }],
    positonCode: [{ required: true, message: "请输入职位代码", trigger: "blur" }]
  },
  addGroupingDialog: {
    GroupName: [{ required: true, message: "请输入分组名称", trigger: "blur" }]
  },
  templateAdd: {
    templateName: [{ required: true, message: "请输入模板名称", trigger: "blur" }],
    templateTheme: [{ required: true, message: "请选择模板主题", trigger: "change" }],
    templateDescribe: [{ required: true, message: "请输入模板描述", trigger: "blur" }],
    templateAuthor: [{ required: true, message: "请输入模板作者", trigger: "blur" }],
    fileType: [{ required: true, message: "请输入模板文件类型", trigger: "change" }],
    fileClass: [{ required: true, message: "请输入模板文件种类", trigger: "change" }],
    languageTypes: [{ required: true, message: "请选择语言类型", trigger: "change" }],
    templateClass: [{ required: true, message: "请选择模板类别", trigger: "change" }],
    templateType: [{ required: true, message: "请选择模板类型", trigger: "change" }],
    subType: [{ required: true, message: "请选择附表类型", trigger: "blur" }],
    uploadFile: [{ required: true, message: "请上传模板", trigger: "change" }]
  }
};

/* 合法uri*/
export function validateURL(textval) {
  const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/;
  return urlregex.test(textval);
}

/* 小写字母*/
export function validateLowerCase(str) {
  const reg = /^[a-z]+$/;
  return reg.test(str);
}

/* 大写字母*/
export function validateUpperCase(str) {
  const reg = /^[A-Z]+$/;
  return reg.test(str);
}

/* 大小写字母*/
export function validatAlphabets(str) {
  const reg = /^[A-Za-z]+$/;
  return reg.test(str);
}

/**
 * validate email
 * @param email
 * @returns {boolean}
 */
export function validateEmail(email) {
  const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(email);
}

/*
 * 验证银行卡
 * 16~19位
 */
export function isBackCard(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("请输入银行卡"));
    // } else if (!/^(\d{16}|\d{19}|\d{23})$/.test(value)) {
    //   callback(new Error("银行卡号应该是16或19位数字"));
    // } else if (/[^0-9]/g.test(value)) {
    //   callback(new Error("银行卡号必须数字"));
    // } else {
  } else {
    callback();
  }
}
/*
 *验证手机号码
 * 国内手机以1开头
 * 11位
 */
export function phoneNumber(rule, value, callback) {
  // var value = parseInt(value);
  // if (!value) {
  //   callback(new Error("请输入手机号码"));
  // } else {
  //   var reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
  //   if (!reg.test(value)) {
  //     callback(new Error("请输入正确的11位手机号码"));
  //   } else {
  //     callback();
  //   }
  // }
  // 因为需求未知，暂时先验证长度
  let phoneNum = value.toString();
  if (!phoneNum) {
    callback(new Error("请输入联系电话"));
    // } else {
    //   if (8 > phoneNum.length || phoneNum.length > 12) {
    //     callback(new Error("请输入正确的联系电话"));
    //   } else {
    //     callback();
    //   }
  } else {
    callback();
  }
}
/*
 *身份证验证
 * 15~18位
 */
export function isCrad(rule, value, callback) {
  // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X (现在只验证18位)
  //	var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;

  if (!value) {
    callback(new Error("请输入身份证号"));
  } else {
    var reg = /(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (!reg.test(value)) {
      callback(new Error("请输入正确的18位身份证号码"));
    } else {
      callback();
    }
  }
}

/*
 *验证税号
 */
export function taxNumber(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("请输入税号"));
  } else if (/[^0-9a-zA-Z]/g.test(value)) {
    callback(new Error("税号格式不符"));
  } else {
    callback();
  }
}

/*
 *非空验证数字
 */
export function isNumber(rule, value, callback) {
  value = String(value);
  if (value.length == 0) {
    callback(new Error("该项不能为空"));
  } else if (value.match(/^(\d*)(\.?)(\d+)$/g) == null) {
    callback(new Error("该项必须为数字"));
  } else {
    callback();
  }
}

/*
 * 数据权限分配·弹框
 * 验证用户选择项
 */
export function isuUserItem(rule, value, callback) {
  if (value.length == 0) {
    callback(new Error("请选择用户"));
  } else {
    callback();
  }
}

/*
 * 数据权限分配·弹框
 * 验证数据角色项
 */
export function isuRoleItem(rule, value, callback) {
  if (value.length == 0) {
    callback(new Error("请选择数据角色"));
  } else {
    callback();
  }
}

/*
 * 采购价格调整
 * 验证整数，小数，+-数字
 */
export function isParseFloat(rule, value, callback) {
  if (!value) {
    callback(new Error("请输入数字或正数或负数"));
  } else {
    let reg = /^(-?(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/;
    if (!reg.test(value)) {
      callback(new Error("请输入数字或正数或负数"));
    } else {
      callback();
    }
  }
}

/*
 * /[0-9a-zA-Z]$/
 * 验证字母数字
 *
 **/

export function isInvoiceNumber(rule, value, callback) {
  if (!value) {
    callback(new Error("请输入发票号码"));
  } else {
    let reg = /[0-9a-zA-Z]$/;
    if (!reg.test(value)) {
      callback(new Error("请输入数字或字母"));
    } else {
      callback();
    }
  }
}
